﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Orion.Lib
{
    public class LaserGun : GraphicElement, IWeapon
    {
        public LaserGun()
        {
            Initialize();
        }
        double lastShot = 0;
        List<LaserParticle> shots = new List<LaserParticle>();

        #region IWeapon Members

        public void Initialize()
        {

        }
        public override void Update(GameTime gameTime)
        {
            shots.ForEach(s => { s.Update(gameTime); });
        }

        //Nested from interfase I weapon;
        public void DrawWeap(GameTime gameTime) { Draw(gameTime); }
        public void UpdateWeap(GameTime gameTime) { Update(gameTime); }

        public override void Draw(GameTime gameTime)
        {
            shots.ForEach(s => { s.Draw(gameTime); });
        }
        

        public void Shoot(GameTime time)
        {
            if (time.TotalGameTime.TotalSeconds - lastShot > this.Delay)
            {
                shots.Add(new LaserParticle() { PossitionX = this.PossitionX + (int)this.Offset.X, PossitionY = this.PossitionY + (int)this.Offset.Y, Color = this.Color });
                lastShot = time.TotalGameTime.TotalSeconds;
            }
        }

        public float Damage
        {
            get { return 10; }
        }

        public float Delay
        {
            get { return 0.5f; }
        }

        Color color = Color.LimeGreen;
        public Color Color
        {
            get { return color; }
            set { color = value; }
        }

        Vector2 offset;
        public Vector2 Offset
        {
            get { return offset; }
            set { offset = value; }
        }

        public bool HasParicles
        {
            get { return shots.Count != 0; }
        }

        bool isRemoved = false;
        public bool IsRemoved
        {
            get { return isRemoved; }
        }

        #endregion
    }
}
